package com.qen.encrypt.properties;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 加解密-公私钥-配置文件
 * @author licz
 * @version 1.0.0
 */
@Getter
@Setter
//@Component
@ToString
@ConfigurationProperties(prefix = "spring.encrypt")
public class EncryptProperties {

    private String defaultKey;
    private String defaultPublicKey;
    private String defaultPrivateKey;
    private String defaultPublicPath;
    private String defaultPrivatePath;
    private String defaultAbsolutePublicPath;
    private String defaultAbsolutePrivatePath;
    private String encryptMode = "AES_CBC";
    private String signMode = "RSA";
    private List<EncryptChild> list = new ArrayList<>();

    @Getter
    @Setter
    public static class EncryptChild {
        private String key;
        private String group;
        private String publicKey;
        private String privateKey;
        private String publicPath;
        private String privatePath;
        private String absolutePublicPath;
        private String absolutePrivatePath;
        private String encryptMode = "AES_CBC";
        private String signMode = "RSA";

        public AlgorithmEnum getEncryptAlgorithmEnum(){
            return AlgorithmEnum.valueOf(encryptMode);
        }

        public AlgorithmEnum getSignAlgorithmEnum(){
            return AlgorithmEnum.valueOf(signMode);
        }

    }

    public AlgorithmEnum getEncryptAlgorithmEnum(){
        return AlgorithmEnum.valueOf(encryptMode);
    }

    public AlgorithmEnum getSignAlgorithmEnum(){
        return AlgorithmEnum.valueOf(signMode);
    }


}
